using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NCS.Module.Multimedia.Library;
using NCS.Module.Multimedia.Library.Bonus;
using NCS.Module.Multimedia.Library.Gallery;
using NCS.Library.Utilities;
using NCS.Library;

namespace NCS.Module.Multimedia.Web.Bonus
{
    public partial class Bonus : GalleryWebControl
    {
        int i = 0;
        int j = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                

                rptTrailer.DataSource = Gallery_BonusController.GetAllCateBonusID(catebonusid);
                //rptTrailer.ItemDataBound += new DataListItemEventHandler(rptTrailer_ItemDataBound);
                rptTrailer.DataBind();
               
            }
        }

        void rptTrailer_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemIndex < 0) return;
            DataRowView currow = (DataRowView)e.Item.DataItem;
            Image imgPic = (Image)e.Item.FindControl("imgPic");
            
            if (ConvertUtility.ToString(currow["BonusAvatar"]) != string.Empty)
            {
                imgPic.ImageUrl = MultimediaUtility.GetBonusAvatar(currow["BonusAvatar"].ToString());
                imgPic.Attributes.Add("onclick", "window.location='" + BuildUrlByBonusId(ConvertUtility.ToInt32(currow["BonusID"])) + "'");
                imgPic.Attributes.Add("style", "cursor:hand");
            }
            else
            {
                imgPic.Visible = false;
            }
            i++;

            Label lblClose = (Label)e.Item.FindControl("lblClose");
            if ((i % 4) == 0)
            {

                lblClose.Text = "</ul></div><div class=\"child c1 first\"><ul class=\"linkedimglinklist18 cf w75\">";
            }
            else
            {
                lblClose.Text = "";
            }
           
        }

   
    }
}